/*  File Name	: Thread.h
 *  Author		: Pang Jiacai
 *	 E-mail		: 823960168@qq.com
 *  Created on	: 2012-9-29
 *  Description:
 */

#ifndef THREAD_H_
#define THREAD_H_

#include "EventHandler.h"

typedef int (*thread_cb_fun)(void*);

class Thread
{
public:
	Thread();
	virtual ~Thread();

	virtual int open(void *cb_ptr,thread_cb_fun cb_fun,bool detached=true,std::string thr_name="",long priority=0);

	virtual int close(int flag=0);

	virtual int put(MessageBlock *mb=0);

	virtual int svc(void);

	virtual pthread_t activate(void);

	virtual int wait(void);

	const pthread_t thread_id(void);
protected:
	static void* run_svc(void *p);

	void *cb_ptr_;
	thread_cb_fun cb_fun_;

	pthread_t thread_id_;
	bool detached_;
	long priority_;
	std::string thr_name_;
};

////////////////////////////////////////

class ThreadManager
{
public:
	ThreadManager();
	virtual ~ThreadManager();

private:

};

#endif /* THREAD_H_ */
